const express = require('express')
const passport = require('../../middlewares/jwtAuthStrategy')
const refreshPassport = require('../../middlewares/authRefreshStrategy')
const {getCurrentUser} = require('../../controllers/usersController/currentUserController')
const {postLogin} = require('../../controllers/usersController/loginController')
const {postRegister} = require('../../controllers/usersController/registerController')
const {postRefreshToken} = require('../../controllers/usersController/refreshTokenController')
const {updateUser} = require('../../controllers/usersController/updateUserController')

const router = express.Router()

router.get('/current', passport.authenticate('jwt', {session: false}), getCurrentUser)

router.post('/login', postLogin)

router.post('/register', postRegister)

router.post('/refresh', refreshPassport.authenticate('refresh', {session: false}), postRefreshToken)

router.post('/update', passport.authenticate('jwt', {session: false}), updateUser)

// router.post('/logout', postLogout)

module.exports = router
